import request from '@/utils/request'

interface ResponseData {
  list: [],
  totalPage: 0,
  total: 0,
}

/**
 * 创建订单
 * @param params
 * @returns
 */
export const createOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/create', data)

/**
 * 创建临时用车订单
 * @param params
 * @returns
 */
export const createTempOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/tempUserCar', data)

/**
 * 作废订单
 * @param params
 * @returns
 */
export const invalidOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/invalid', data)

/**
 * 分页查询订单
 * @param params
 * @returns
 */
export const orderQuery = <T>(data?: any) =>
  request.post<ResponseData>('/admin-core/web/order/v1/queryPage', data)

/**
 * 更新订单
 * @param params
 * @returns
 */
export const updateOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/update', data)

/**
 * 订单调度
 * @param params
 * @returns
 */
export const orderDispatch = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/orderDispatch', data)

//临时调度订单
export const orderTempDispatch = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/orderTempDispatch', data)

/**
 * 新增的订单导出  /admin-core/web/order/v1/exportOrder  也只有管理员才有按钮
 * @param params
 * @returns
 */
export const exportOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/exportOrder', data, {
    responseType: 'blob',
  })

// 新增的订单导出  /admin-core/web/order/v1/exportOrder  也只有管理员才有按钮
// 订单分页查询条件
// 1. 根据创建时间查询  参数 startCreateTime 和 endCreateTime
// 2 根据订单来源查询 参数 orderSource

/**
 * 查询订单详情
 * @param params
 * @returns
 */
export const queryOrderDetail = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/queryDetail', data)


/**
 * 根据司机查询绑定的车
 * @param params
 * @returns
 */
export const queryCarByDriverUuid = <T>(data?: any) =>
  request.post<T>('/admin-core/web/carDriverBind/v1/queryCarByDriverUuid', data)

/**
 * 查询调度企业信息
 * @param params
 * @returns
 */
export const queryDispatchList = <T>(data?: any) =>
  request.post<T>('/admin-core/web/partner/v1/queryDispatchList', data)


// /web/order/v1/allocateOrder 分配订单接口
export const allocateOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/allocateOrder', data)

/**
 * 加入订单池
 * @param params
 * @returns
 */
export const joinOrderPool = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/joinOrderPool', data)

/**
 * 移出订单池
 * @param params
 * @returns
 */
export const shiftOutOrderPool = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/shiftOutOrderPool', data)

/**
 * 结束订单
 * @param params
 * @returns
 */
export const finishOrder = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/finishOrder', data)

/**
 * 查询订单时间分布
 * @param params
 * @returns
 */
export const queryOrderTimeDistribution = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/queryOrderTimeDistribution', data)

/**
 * 上传订单照片
 * @param params
 * @returns
 */
export const uploadOrderPhoto = <T>(data?: any) =>
  request.post<T>('/admin-core/web/order/v1/uploadPhoto', data)
